package com.engineering.elink.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.filter.OncePerRequestFilter;

public class OriginFilter extends OncePerRequestFilter{
	
	private Logger log=Logger.getLogger(OriginFilter.class);

	@Override
	protected void doFilterInternal(HttpServletRequest request,
			HttpServletResponse response, FilterChain filterChain)
			throws ServletException, IOException {
		
		log.info("这个过滤器只执行一次！！！");
			
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Access-Control-Allow-Origin", "*");
//		response.setHeader("Content-Type", "application/json;charset=UTF-8");
		filterChain.doFilter(request, response);
	}

}
